// src/store/index.js
// store.js
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        userType: 'none', // 初始化 userType
        isAuthenticated: false, // 登录状态
    },
    mutations: {
        setUserType(state, userType) {
            state.userType = userType;
        },
        setAuthenticated(state, status) {
            state.isAuthenticated = status;
        },
    },
    actions: {
        setUserType({ commit }, userType) {
            commit('setUserType', userType);
        },
        setAuthenticated({ commit }, status) {
            commit('setAuthenticated', status);
        },
    },
    getters: {
        userType: state => state.userType,
        isAuthenticated: state => state.isAuthenticated,
    },
});